package work823;

import java.io.*;
import java.net.*;
import java.util.Scanner;

public class work7Thread extends Thread {
  private Socket s;


  public work7Thread(Socket s) {
    this.s = s;
  }

  @Override
  public void run() {
    Scanner sc = new Scanner(System.in);
    try {
      OutputStream os = s.getOutputStream();
      InputStream is = s.getInputStream();
      BufferedReader br = new BufferedReader(new InputStreamReader(is));
      BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
      while (true) {
        String str1;
        while ((str1 = br.readLine()) != null) {
          System.out.println(str1);
        }
        if (!sc.next().equals("1")){
          String str2 = "管理员说：" + sc.next();
          bw.write(str2);
          bw.newLine();
          bw.flush();
          s.shutdownOutput();
        }
         s.shutdownInput();
      }

    } catch (IOException e) {
      e.printStackTrace();
    }

  }

}
